/**
 * @module navigator页面跳转
 */

import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import { NavigationParams } from 'react-navigation';

/**
 * @see [react-native官方文档](https://reactnavigation.org/docs/zh-Hans/navigation-prop.html)
 * @param fd: IFeidaoAiMobile;	// 系统参数
 * @param options: {
 *
 * routeName: string; // 页面名
 *
 * params?: NavigationParams; //向跳转页面传入的参数
 *
 * };
 * @see [api](https://dfeidao.gitee.io/feidao-web/browser/local)
 * @example
 * ```ts
 * import navigate from '@dfeidao/atom-mobile/navigator/navigate';
 * navigate({ routeName: 'home', params: { id: '', name: '' } }); // 带参数
 * navigate({ routeName: 'home' }); // 不带参数
 * ```
 */

export default function navigate(fd: IFeidaoAiMobile, options: {
	routeName: string;
	params?: NavigationParams;
}) {
	const opt = { ...options, key: new Date().getTime().toString() };
	fd.page.props.navigation.navigate(opt);
	return opt.key;
}
